package com.example.administrator.yuejian_2.adapter;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.RecyclerView.Adapter;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.example.administrator.yuejian_2.R;
import com.example.administrator.yuejian_2.bean.ClubCourseListBean;
import com.example.administrator.yuejian_2.viewholder.ClubCourseViewHolder;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by Administrator on 2017/10/24.
 */

public class ClubCourseListAdapter extends Adapter {


    private List<ClubCourseListBean> course = new ArrayList<>();
    private Context context;
    private LayoutInflater layoutInflater;


    public ClubCourseListAdapter(Context context, List<ClubCourseListBean> course){
        this.context = context;
        layoutInflater = LayoutInflater.from(context);
        this.course.addAll(course);

    }




    @Override
    public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {

        View itemView = layoutInflater.inflate(R.layout.item_course,parent,false);
        ClubCourseViewHolder holder = new ClubCourseViewHolder(itemView);
        return holder;
    }

    @Override
    public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
        ClubCourseViewHolder courseholder = (ClubCourseViewHolder) holder;
        ClubCourseListBean courselist = course.get(position);


        String course_name = courselist.getCourse_name();
        courseholder.coursename.setText(course_name);

        String course_intro = courselist.getCourse_intro();
        courseholder.courseintro.setText(course_intro);

        String course_money = courselist.getCourse_money();
        courseholder.coursemoney.setText(course_money);


    }

    @Override
    public int getItemCount() {
        return course.size();
    }



}
